package com.atguigu.tingshu.order.api;

import com.atguigu.tingshu.common.login.GuiLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.order.OrderInfo;
import com.atguigu.tingshu.order.service.OrderInfoService;
import com.atguigu.tingshu.vo.album.TrackInfoVo;
import com.atguigu.tingshu.vo.order.OrderInfoVo;
import com.atguigu.tingshu.vo.order.TradeVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mysql.cj.x.protobuf.MysqlxCrud;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.configuration.hints.SpringDocUiHints;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "订单管理")
@RestController
@RequestMapping("/api/order/orderInfo")
public class OrderInfoApiController {

	@Autowired
	private OrderInfoService orderInfoService;

	/**
	 * 订单确认
	 * @param tradeVo
	 * @return
	 */
	@GuiLogin
	@PostMapping("/trade")
	public Result trade (@RequestBody TradeVo tradeVo){

		return Result.ok(orderInfoService.trade(tradeVo));

	}


	/**
	 * 订单提交
	 * @return
	 */
	@GuiLogin
	 @PostMapping("/submitOrder")
	public Result submitOrder(@RequestBody OrderInfoVo orderInfoVo){
		return Result.ok(orderInfoService.submitOrder(orderInfoVo));
	 }

	/**
	 * 用户订单列表
	 * @param page
	 * @param size
	 * @return
	 */
	@GuiLogin
	 @GetMapping("/findUserPage/{page}/{size}")
	 public Result findUserPage(@PathVariable(value = "page")Long page,
								@PathVariable(value = "size")Long size){

		return Result.ok( orderInfoService.findUserPage(new Page<OrderInfo>(page,size)));
	 }


	/**
	 * 获取订单详情
	 * @param orderNo
	 * @return
	 */
	 @GuiLogin
	 @GetMapping(value = "/getOrderInfo/{orderNo}")
	public Result<OrderInfo> getOrderInfo (@PathVariable(value = "orderNo") String orderNo){
		return Result.ok(orderInfoService.getOrderInfo(orderNo));
	 }


	/**
	 * 订单支付，支付渠道，订单号
	 * @param payway
	 * @param orderNo
	 * @return
	 */
	@GuiLogin
	@GetMapping("/getOrderPayInfo/{payway}/{orderNo}")
	public Result getOrderPayInfo(@PathVariable(value = "payway")String payway,
								  @PathVariable(value = "orderNo")String orderNo){
		return Result.ok(orderInfoService.getOrderPayInfo(payway, orderNo));
	}





}

